<template>
	<el-drawer title="政务信息详情" v-model="visible" :size="800" destroy-on-close @closed="$emit('closed')">
		<el-container>
			<el-main>
				<el-header style="display: block;text-align: center">
					<div style="text-align: center;display: inline;font-weight: 600;font-size: 16px">
						{{ form.title }}
					</div>
				</el-header>
				<el-main>
					<span v-html="form.content"></span>
					<el-form-item label="相关附件" v-if="form.attachId!=''">
						<attach-menu :attachIds="form.attachId" :roleFlag="form.attachRole" :preview="true"></attach-menu>
					</el-form-item>
					<div style="margin-top: 20px;text-align: right;">
						<div style="float: left;">
							【{{ form.infoTypeName }}】{{ form.createUserName }}
						</div>
						<span style="margin-left: 20px">发布时间：{{ form.sendTime }}</span>
					</div>
				</el-main>
				<el-footer style="text-align: center;">
					<el-button @click="visible=false">关闭</el-button>
				</el-footer>
			</el-main>
		</el-container>
	</el-drawer>
</template>
<script>
import AttachMenu from "@/views/module/attachMenu.vue";

export default {
	name: 'Open Info Details',
	components: {AttachMenu},
	data() {
		return {
			form: {
				createUserName: '',
				title: '',
				infoTypeName: '',
				content:'',
				createTime: '',
				attachId:'',
				attachRole:'1',
			},
			model:"read",
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {
	},
	methods: {
		open(model){
			this.model=model;
			this.visible = true;
			return this;
		},
		setData(data){
			this.form.createUserName=data.createUserName
			this.form.infoTypeName =data.infoTypeName
			this.form.infoType=data.infoType
			this.form.content = data.content
			this.form.title = data.title
			this.form.sendTime=data.sendTime
			this.form.attachRole = data.attachRole
			this.form.attachId = data.attachId
			if(this.model=='read')
			{
				this.setOpenInfoReaderUser(data.recordId);
			}
		},
		async setOpenInfoReaderUser(recordId)
		{
			await this.$API.info.openInfo.setOpenInfoReaderUser.post({recordId:recordId});
		},
		async getOpenInfoById(data)
		{
			let res = await this.$API.info.openInfo.getOpenInfoById.get({recordId:data});
			{
				if(res.code==200)
				{
					this.form.createUserName=res.data.createUserName
					this.form.infoTypeName =res.data.infoTypeName
					this.form.infoType=res.data.infoType
					this.form.content = res.data.content
					this.form.title = res.data.title
					this.form.sendTime=res.data.sendTime
					this.form.attachRole = res.data.attachRole
					this.form.attachId = res.data.attachId
					this.setOpenInfoReaderUser(data);
				}else
				{
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}
	}

}
</script>

<style>
</style>
